package com.yict.csms.resourceplan.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.yict.common.dao.impl.CommonDao;
import com.yict.csms.resourceplan.dao.IRtgcFlWhartNeedDao;
import com.yict.csms.resourceplan.entity.RtgcFlWhartNeed;
import com.yict.csms.resourceplan.entity.RtgcFlWhartNeedHour;

@Repository("rtgcFlWhartNeedDao")
public class RtgcFlWhartNeedDaoImpl extends CommonDao<RtgcFlWhartNeed, Long> implements IRtgcFlWhartNeedDao {

	public boolean saveOrUpdateByNeedHour(List<RtgcFlWhartNeedHour> t) throws Exception {
		boolean bool = false;
		try {
			this.getTemplate().saveOrUpdateAll(t);
			bool = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return bool;
	}
	
	public List<RtgcFlWhartNeedHour> findByNeedHourTimeId(String timeId){
		String queryString = "from RtgcFlWhartNeedHour r where r.rtgcFlTime.timeid='"+timeId+"'";
		List<RtgcFlWhartNeedHour> list = new ArrayList<RtgcFlWhartNeedHour>();
		try {
			if(timeId!=null&&!"".equals(timeId)){
			list = this.getTemplate().find(queryString);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
}
